from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
# from lian822 import ku
from Tools import Tools
import time,unittest

class A3mall(unittest.TestCase):
    def setUp(self):
        Tools().Log2()
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.driver.get('http://10.59.9.12:7001/')

    def tearDown(self):
        time.sleep(3)
        self.driver.quit()

    def test_a3mall_01_login(self):
        # selec = ku.A3mall_db(user='root', password='yidong666', host='10.59.9.12', database='a3mall')
        self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
        dy1 = self.driver.find_element(By.CLASS_NAME,'reg-new').text
        print(dy1)
        self.driver.find_element(By.NAME,'username').send_keys('18620064667')
        self.driver.find_element(By.NAME,'password').send_keys('123456')
        time.sleep(10)
        self.driver.find_element(By.CLASS_NAME,'finish-btn').click()
        time.sleep(5)
        dy2 = self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[4]/span').text
        dy21 = dy2.replace('¥ ','')
        print(dy21)
        # dy211 = selec.select('select amount from mall_users where username="18620064667"')
        # assert float(dy21)==float(dy211[0][0])
        self.driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/ul/li[1]/a').click()
        sou = self.driver.find_element(By.CLASS_NAME, 'search-input')
        sou.send_keys('非洲之心')
        sou.send_keys(Keys.ENTER)
        self.driver.find_element(By.XPATH,'//img[@src="/uploads/images/20250606/af9ef24936d60ea1dfe55120bccc1906.png"]').click()
        self.driver.find_element(By.ID, 'buy-cart').click()
        self.driver.find_element(By.ID, 'address-828').click()
        self.driver.find_element(By.ID, 'order-button').click()
        time.sleep(1)
        self.driver.find_element(By.XPATH, '/html/body/div[4]/div[3]/p/a').click()

    @unittest.skip
    def test_a3mall_02(self):
        self.test_a3mall_01_login()
        self.driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/ul/li[1]/a').click()
        sou = self.driver.find_element(By.CLASS_NAME, 'search-input')
        sou.send_keys('非洲之心')
        sou.send_keys(Keys.ENTER)
        self.driver.find_element(By.XPATH,'//img[@src="/uploads/images/20250606/af9ef24936d60ea1dfe55120bccc1906.png"]').click()
        self.driver.find_element(By.ID, 'buy-cart').click()
        self.driver.find_element(By.ID, 'address-828').click()
        self.driver.find_element(By.ID, 'order-button').click()
        time.sleep(1)
        self.driver.find_element(By.XPATH,'/html/body/div[4]/div[3]/p/a').click()

if __name__ == '__main__':
    unittest.main()